<script setup>
import { ref } from 'vue'
import axios from 'axios'

defineProps({
  msg: String,
})

const password = ref()
const generatePassword = () => {
  // 向给定ID的用户发起请求
  axios.get('/receiveapi/api/generatePassword')
    .then(function (response) {
      // 处理成功情况
      password.value = response.data
    })
    .catch(function (error) {
      // 处理错误情况
      window.alert("请求失败:", error)
    })
}
</script>

<template>
  <h1>{{ msg }}</h1>

  <div class="card">
    <button type="button" @click="generatePassword()">生成密码</button>
  </div>

  <p>
    {{password}}
  </p>
</template>

<style scoped>
.read-the-docs {
  color: #888;
}
</style>
